#!/bin/sh
PATH=$PATH:/home/oracle/scripts ; export PATH
LOG=/tmp/stopdb.log
MSG_LOG=/oracle/newbackup/log/joblog_`date +%Y%m`.log ;export MSG_LOG
JOBNAME=Stop_DB          ; export JOBNAME

MSG_JOB S
lsnrctl stop
RC=$?
if [[ $RC != 0 ]]
then
  MSG_JOB E "Listener Stop Failed"
  exit 1
else
  MSG_JOB I "Stop Listener Successfully"
fi
sleep 10

sqlplus /nolog <<EOF
conn /as sysdba
shutdown immediate
exit
EOF
RC=$?
if [[ $RC != 0 ]]
then
  MSG_JOB E "DB Stop Failed"
  exit 1
else
  MSG_JOB I "Stop Database Successfully"
fi
sleep 10
MSG_JOB N
